StringUtils = function() {
	this.html_encode = function(str) {
		if (typeof str != "string")
			return str;
		var s = "";
		if (str.length == 0)
			return "";
		s = str.replace(/&/g, "&gt;");
		s = s.replace(/</g, "&lt;");
		s = s.replace(/>/g, "&gt;");
		s = s.replace(/ /g, "&nbsp;");
		s = s.replace(/\'/g, "&#39;");
		s = s.replace(/\"/g, "&quot;");
		s = s.replace(/\n/g, "<br>");
		return s;
	};

	this.html_decode = function(str) {
		if (typeof str != "string")
			return str;
		var s = "";
		if (str.length == 0)
			return "";
		s = str.replace(/&gt;/g, "&");
		s = s.replace(/&lt;/g, "<");
		s = s.replace(/&gt;/g, ">");
		s = s.replace(/&nbsp;/g, " ");
		s = s.replace(/&#39;/g, "\'");
		s = s.replace(/&quot;/g, "\"");
		s = s.replace(/<br>/g, "\n");
		return s;
	};
	// 去左空格;
	this.ltrim = function(s) {
		return s.replace(/(^s*)/g, "");
	};
	// 去右空格;
	this.rtrim = function(s) {
		return s.replace(/(s*$)/g, "");
	};
	// 去左右空格;
	this.trim = function(s) {
		// s.replace(/(^s*)|(s*$)/g, "");
		return this.rtrim(this.ltrim(s));
	};
};
StringUtils.call(StringUtils);
